import Vue from 'vue'
import Vuex from 'vuex'

import getters from './getters'

// ! 遍历文件生成 modules
const files = require.context('./modules', false, /\.js$/)
const modules = {}

files.keys().forEach((key) => {
  modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
})

Object.keys(modules).forEach((key) => {
  modules[key]['namespaced'] = true
})

Vue.use(Vuex)

const store = new Vuex.Store({
  modules,
  getters,
  state: {
  },
})

export default store
